#ifndef TRANSFORMCOMPONENT_H
#define TRANSFORMCOMPONENT_H

#include "Component.h" // Base class: Component
#include "ComponentFactory.h"

#include "core/Object.h"
#include "gameobjects/GameObject.h"

//!TODO: non-copyable?
class TransformComponent : public Component
{
public:
	TransformComponent() : Component("TransformComponent"),
		mPos(0), mScale(0), mOrient(0), mGo(0), mSceneNode(0)
	{}

	TransformComponent(ComponentContainer* c) :	Component(c, "TransformComponent"),
		mPos(0), mScale(0), mOrient(0), mGo(0), mSceneNode(0)
	{ init(); }

	TransformComponent(ComponentContainer* c, const std::string& name) : Component(c, name),
		mPos(0), mScale(0), mOrient(0), mGo(0), mSceneNode(0)
	{ init(); }

	TransformComponent(ComponentContainer* c, const std::string& name, Ogre::SceneNode* node) :	Component(c, name),
		mPos(0), mScale(0), mOrient(0), mGo(0), mSceneNode(node)
	{ init(); }

	virtual ~TransformComponent() {}

	inline std::string toString(void) const { return "TransformComponent"; }

	void init();

	inline void setPosition() { mSceneNode->setPosition(*mPos);	}
	inline void setOrientation() { mSceneNode->setOrientation(*mOrient); }
	inline void setScale() { mSceneNode->setScale(*mScale);	}

	::Object* mTrans;

private:
	void _update();
	void _clear();
	void _reconnect();
	
//	bool dirty;
	sigc::connection posCon;
	sigc::connection rotCon;
	sigc::connection scaleCon;

protected:

	Property<Vector3>* mPos;
	Property<Vector3>* mScale;
	Property<Quaternion>* mOrient;

	GameObject* mGo;
	SceneNode* mSceneNode;
};


#endif // TRANSFORMCOMPONENT_H
